<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body,
        html {
            width: 100%;
            height: 100%;
        }

        .box {
            width: 100%;
            height: 100%;
        }

        .box ul {
            width: 100%;
            height: 100%;
            list-style: none;
            position: relative;
        }

        .box ul li {
            width: 250px;
            height: 360px;
            /*border: 1px solid #000;*/
            position: absolute;
            /*left: 0;*/
            /*top: 0;*/
            background-color: #fff;
            transition: all 1s;
            box-shadow: 0 0 3px #000;
        }

        .box li img {
            width: 250px;
            height: 360px;
        }

        .box ul li.curr {
            transform: rotate(0deg) translate(-50%, -50%) scale(1.5) !important;
            /*transform: rotate(90deg) !important;*/
            left: 50% !important;
            top: 50% !important;
            z-index: 998;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li><img src="./images/01.jpg" alt=""></li>
            <li> <img src="./images/02.jpg" alt=""></li>
            <li> <img src="./images/03.jpg" alt=""></li>
            <li> <img src="./images/04.jpg" alt=""></li>
            <li> <img src="./images/05.jpg" alt=""></li>
            <li> <img src="./images/06.jpg" alt=""></li>
            <li> <img src="./images/07.jpg" alt=""></li>
            <li> <img src="./images/08.jpg" alt=""></li>
            <li> <img src="./images/09.jpg" alt=""></li>
            <li> <img src="./images/10.jpg" alt=""></li>
        </ul>
    </div>
    <script>
        var box = document.querySelector('.box');
        var ul = document.querySelector('ul');
        var li = document.querySelectorAll('li');
        //获取屏幕的宽度和高度
        var screenW = document.documentElement.clientWidth - 350;
        var screenH = document.documentElement.clientHeight - 350;

        //遍历图片
        for (var index = 0; index < li.length; index++) {
            // 接受每个图片
            var ol = li[index]
            //获取随机数
            var X = getRandom(0, screenW);
            var Y = getRandom(0, screenH);
            //获取图片距离左与上边的距离
            ol.style.left = X + 'px';
            ol.style.top = Y + 'px';
            //旋转角度随机
            var angle = getRandom(0, 360);
            //样式设置旋转
            ol.style.transform = 'rotate(' + angle + 'deg)';
            //添加点击事件
            ol.addEventListener('click', function () {

                //清空其他所有
                for (var k = 0; k < li.length; k++) {
                    li[k].className = ''
                }
                //设置当前
                this.className = 'curr'
            })

        }
        function getRandom(min, max) {
            // 0.9999999 * (100 - 50 + 1) + 50 = 95.9 约等于 95
            return Math.floor(Math.random() * (max - min + 1) + min);
        }


    </script>
</body>

</html>